﻿using Vin.Tool.Attributes;
using Vin.Tool.Core.EnumCategory;

namespace Vin.Extension.Framework.Login.Attributes;

public enum VinLoginType
{
    /// <summary>
    /// 密码
    /// </summary>
    Password = 1,
    
    /// <summary>
    /// 手机号验证码
    /// </summary>
    PhoneCode = 10,

    /// <summary>
    /// 邮箱验证码
    /// </summary>
    EmaildCode = 20,
    
    /// <summary>
    /// 微信扫码
    /// </summary>
    WxQrCode = 30,
    
}

public enum VinLoginHandleType
{
    /// <summary>
    /// 密码
    /// </summary>
    Password = 1,
    
    /// <summary>
    /// 验证码
    /// </summary>
    Code = 10,
    
    /// <summary>
    /// 扫码
    /// </summary>
    QrCode = 20,
}


public class VinLoginServiceAttribute : ServiceAttribute
{
    /// <summary>
    /// 处理器唯一标识 (代表当前处理器的登录方式，比如手机验证码登录【10】,密码登录【1】，微信扫码登录【30】,邮箱验证码登录【20】)
    /// </summary>
    public string LoginType { get; set; }

    /// <summary>
    /// 处理器类型 (代表当前处理器的登录方式，比如验证码登录【10】,密码登录【1】，扫码登录【20】)
    /// </summary>
    public string LoginHandleType { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    public string Way { get; set; } = string.Empty;

    /// <summary>
    /// 图标
    /// </summary>
    public string Icon { get; set; } = string.Empty;

    /// <summary>
    /// 是否可以绑定
    /// </summary>
    public bool CanBind { get; set; }

    /// <summary>
    /// 是否默认
    /// </summary>
    public bool Default { get; set; }

    public VinLoginServiceAttribute(string loginType, string loginHandleType, bool canBind = true, bool @default = false)
    {
        LoginType = loginType;
        LoginHandleType = loginHandleType;
        CanBind = canBind;
        Default = @default;
        Key = loginType;
    }
    
    public VinLoginServiceAttribute(VinLoginType loginType, VinLoginHandleType loginHandleType, bool canBind = true, bool @default = false)
    {
        LoginType = loginType.GetName();
        LoginHandleType = loginHandleType.GetName();
        CanBind = canBind;
        Default = @default;
        Key = this.LoginType;
    }
}